import { defineComponent } from 'vue';
import WrapTitle from '@common/wrapTitle';

const createScrollEl = (value, direction = 'left') => (
  <marquee behavior="scroll" direction={direction} scrolldelay={200}>
    {value}
  </marquee>
);

export default defineComponent({
  name: 'BusinessInfo',
  props: {
    data: Array,
  },
  render(props: any) {
    return (
      <div id="BusinessInfo">
        <WrapTitle title="工商信息" img="longtitle.png"></WrapTitle>
        <ul>
          {props.data?.map((info: any) => {
            // 处理数据
            let value;
            switch (info.key) {
              case 'legal_person_type': // 法人类型
                value =
                  {
                    1: '个人',
                    2: '公司',
                  }[info.value] || '-';
                break;
              case 'reg_institute': // 等级机关
                value = info.value?.length > 12 ? createScrollEl(info.value) : info.value;
                break;
              case 'phone_number': //企业联系方式
                value = info.value?.length > 20 ? createScrollEl(info.value) : info.value;
                break;
              case 'reg_location': // 注册地址
                value = info.value?.length > 24 ? createScrollEl(info.value) : info.value;
                break;
              case 'business_scope':
                value = createScrollEl(info.value, 'up');
                break;
              default:
                value = info.value;
                break;
            }

            return (
              <li class={info?.key === 'reg_location' ? 'lix2' : ''}>
                <header>{info.label}</header>

                <section>{value}</section>
              </li>
            );
          })}
        </ul>
      </div>
    );
  },
});
